package com.hao.tool.extra.cloud.module.yiyuan;

import com.hao.tool.extra.cloud.exception.ResultException;
import com.hao.tool.extra.cloud.module.yiyuan.dto.VehicleScoreDTO;
import com.hao.tool.extra.cloud.module.yiyuan.fac.YYFactory;
import com.hao.tool.extra.cloud.module.yiyuan.res.VehicleScoreResult;

import java.io.IOException;

/**
 * description
 *
 * @author RuiHaoZ on CMHK.jx
 * @date 2020-07-25 11:50
 */
public class YYManager {

    public static String authorization;

    static {
        YYManager.setAuth("APPCODE bc8974e492a14914b1705717b645206b");
    }

    public static void setAuth(String authorization) {
        YYManager.authorization = authorization;
    }


    public static VehicleScoreResult build(String url, VehicleScoreDTO scoreDTO) throws ResultException {
        YYFactory wsFactory = new YYFactory();
        wsFactory.setAuthorization(authorization);
        VehicleScoreResult scoreResult = null;
        try {
            scoreResult = wsFactory.execute(url, scoreDTO);
        } catch (IOException e) {
            throw new ResultException(0, e.getMessage());
        }
        return scoreResult;
    }
}
